using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UIConfigMgr : Singleton<UIConfigMgr>
{
    Dictionary<UINAMES, UIItemCfg> Dic = new Dictionary<UINAMES, UIItemCfg>();
    public override async void Init()
    {
        base.Init();

        var assetPath = "Assets/Scripts/UI/UIConfig.asset";
        var Cfg = await LoadMgr.Instance.LoadAsset<UIConfig>(assetPath);
        Dic.Clear();
        foreach (var item in Cfg.Dic)
        {
            Dic.Add(item.Name, item);
        }
    }

    //通过name查找UIItem
    public UIItemCfg GetUIItem(UINAMES name)
    {
        if(Dic.ContainsKey(name))
        {
            return Dic[name];
        }
        return null;
    }

    public Dictionary<UINAMES, UIItemCfg> GetDic()
    {
        return Dic;
    }
    public override void OnDestory()
    {
        Debug.Log("UIConfigMgr.OnDestory");
        base.OnDestory();
    }
}